package com.lovo.javafxComponent;

import java.util.Optional;

import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonType;

/**
 * 对话框组件
 * 
 * @author lenovo
 *
 */
public class LovoDialog {

	/**
	 * 消息框
	 * 
	 * @param info
	 *            消息内容
	 */
	public static void showMessageDialog(String info) {
		Alert alert = new Alert(AlertType.INFORMATION);
		alert.setTitle(null);
		alert.setHeaderText(null);
		alert.setContentText(info);

		alert.showAndWait();
	}

	/**
	 * 确认对话框
	 * @param info 消息内容
	 * @return 选择按钮，“确定”---0  “取消”----1
	 */
	public static int showConfirmDialog(String info) {

		Alert alert = new Alert(AlertType.CONFIRMATION);
		alert.setTitle(null);
		alert.setHeaderText(null);
		alert.setContentText(info);

		Optional<ButtonType> result = alert.showAndWait();
		if (result.get() == ButtonType.OK) {
			return 0;
		} else {
			return 1;
		}
	}
}
